package com.cloud.bc.controller.pc;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.bc.controller.BaseController;
import com.cloud.bc.model.entity.BcArticles;
import com.cloud.bc.model.entity.BcMomen;
import com.cloud.bc.model.request.MomenRequest;
import com.cloud.bc.service.BcArticlesService;
import com.cloud.bc.service.BcMomenService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

//PC动态圈
@Controller
@AllArgsConstructor
@RequestMapping("moment")
public class PcMomentController extends BaseController {

    private final BcArticlesService bcArticlesService;
    private final BcMomenService bcMomenService;

    /**
     * 动态
     */
    @GetMapping("")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response, Integer current) {
        ModelAndView view = baseView(request,"51找朋友", "pc/moment/index");
        //脱单宝典
        IPage<BcArticles> bcArticlesIPageRight = bcArticlesService.selectPage(new Page(1, 10), null);
        view.addObject("article", bcArticlesIPageRight.getRecords());
        view.addObject("bodyCss", "page-moment-index");
        return view;
    }
    /**
     * 创建动态
     */
    @GetMapping("create")
    public ModelAndView create(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"创建动态", "pc/moment/create");
        String mediaType = request.getParameter("media_type");
        //默认是图片动态
        mediaType = StrUtil.isEmpty(mediaType) ? "image" : mediaType;
        view.addObject("mediaType", mediaType);
        IPage<BcArticles> bcArticlesIPageRight = bcArticlesService.selectPage(new Page(1, 10), null);
        view.addObject("article", bcArticlesIPageRight.getRecords());
        return view;
    }
}
